<?php 


class AuthPlugin extends Zend_Controller_Plugin_Abstract
{
	public function preDispatch(Zend_Controller_Request_Abstract $request)
	{
		
		
		if (Zend_Auth::getInstance ()->hasIdentity ()) {
			if ('logout' == $this->getRequest()->getActionName ()) {
				$auth = Zend_Auth::getInstance();
				$auth->clearIdentity();
				$this->getRequest ()->setModuleName("admin")
									->setControllerName("authentification")
									->setActionName("logout") 
									->setDispatched(false);
			}
		} else {
			if ('login' != $this->getRequest ()->getActionName ()) {
				
				$this->getRequest ()->setModuleName("admin")
									->setControllerName("authentification")
									->setActionName("login") 
									->setDispatched(false);
				
			}
		}
		
	
	}
	
	
	
	
}